package br.com.werp.regras.geral.imagens;

import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

/**
 * @author Sobreira
 * Created on 08/11/2004
 */
public class CarregadorImagens {
    public static final CarregadorImagens instancia = new CarregadorImagens();
    
    public static byte[] carregaImagem(String nome) throws IOException{
 	    DataInputStream inputStream= new DataInputStream(  
 	        instancia.getClass().getResourceAsStream(nome));
 	    //ZipInputStream zipInputStream = new ZipInputStream(inputStream);
 	    byte[] imagem = new byte[inputStream.available()];
 	    inputStream.readFully(imagem);
        return imagem;
    }
    
    public static InputStream carregaStreamImagem(String nome) throws IOException{
    	InputStream stream = instancia.getClass().getResourceAsStream(nome);    	
    	return stream; 	             
    }
    
    public static URL carregaURLImagem(String nome) throws IOException{
    	URL url = instancia.getClass().getResource(nome);    	
    	return url; 	             
    }
    
    public static File carregaFileImagem(String nome) throws IOException{
    	File file = new File( nome );    	
    	return file; 	             
    }
        
    public static void main(String[] args) throws IOException {
    	System.out.println(System.getProperties());
    	//System.out.println(instancia.getClass().getPackage());
/*        FileOutputStream fileOutputStream = new FileOutputStream("testasdae.bmp");
        fileOutputStream.write(carregaImagem("Uniodonto.bmp"));
        fileOutputStream.close();*/
    }
}
